﻿using System;

using Kiiro.Common.Utility;

namespace Kiiro.SiteDefinition.ApplicationPages
{
    public partial class Smart404 : System.Web.UI.Page
    {
        protected override void OnPreInit ( EventArgs e )
        {
            string requestUrl = this.Request.Params [ "oldUrl" ];

            if ( !string.IsNullOrEmpty ( requestUrl ) )
            {
                string webAbsUrl = requestUrl.Substring ( 0, requestUrl.LastIndexOf ( '/' ) );

                Guid siteCollectionId = default ( Guid );
                string serverRelativeUrl = default ( string );
                SPHelpers.GetSiteCollectionIdAndServerRelativeUrl ( webAbsUrl, out siteCollectionId, out serverRelativeUrl );

                if ( !SPHelpers.IsKiiro ( siteCollectionId, serverRelativeUrl ) )
                {
                    base.Response.Clear ( );
                    base.Response.StatusCode = 404;
                    base.Response.Flush ( );
                    base.Response.End ( );
                }
            }

            base.OnPreInit ( e );
        }

        protected void Page_Load ( object sender, EventArgs e )
        {
        }
    }
}

/*************************************************************************
 * 
 * $Log: /Internal Projects/Kiiro/Kiiro.SiteDefinition/12/TEMPLATE/FEATURES/Kiiro.ApplicationPages/ApplicationPages/Smart404.aspx.cs $
 * 
 * 10    2/08/10 5:04p Camerons
 * 
 * 9     1/25/10 1:17p Camerons
 * 
 * 8     1/12/10 12:03p Camerons
 * 
 * 7     26/11/09 10:35a Camerons
 * 
 * 6     17/11/09 6:46p Camerons
 * 
 * 5     22/09/09 6:03p Camerons
 * Code changes to support creating user on demand - version 1.1.x.x
 * 
 * 4     17/08/09 11:07a Camerons
 * Added check-in comments section
 * 
 ************************************************************************/